package org.genntii.warehousesystem.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.genntii.warehousesystem.Exception.ParamErrorException;
import org.genntii.warehousesystem.common.Result;
import org.genntii.warehousesystem.domain.entity.Brand;
import org.genntii.warehousesystem.mapper.BrandMapper;
import org.genntii.warehousesystem.service.BrandService;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements BrandService {

    @Resource
    private BrandMapper brandMapper;

    @Override
    public void add(String brandName) {
        Brand brand = new Brand();
        brand.setBrand(brandName);
        brandMapper.insert(brand);
    }

    @Override
    public void del(int id) {
        Brand brand = brandMapper.selectById(id);
        if (brand == null){
            throw new ParamErrorException("参数有误");
        }
        brandMapper.deleteById(id);
    }

    @Override
    public List<Brand> showAllByPage(int page) {
        List<Brand> list = brandMapper.showAllByPage(10*(page-1));
        return list;
    }

    @Override
    public List<Brand> showAllBrand() {
        List<Brand> list = brandMapper.showAllBrand();
        return list;
    }

}
